import { defineStore } from 'pinia'
import { computed, ref } from 'vue'

export const useCounterStore = defineStore('counter',()=>{

  const totalCount = ref(0)

    // actions 修改数据
    const addTotalCount = (value: number) => {
      totalCount.value += value
    }
  
    // getters 计算属性
    const dobuleTotalCount = computed(() => {
      return totalCount.value * 2
    })
  return {totalCount,addTotalCount,dobuleTotalCount}
},{persist:true} )// 持久化

